<template>
  <AMISRenderer :schema="schema" />
</template>

<script setup>
import AMISRenderer from '@/components/AMISRenderer.vue'
import addPage from './add'
import editPage from './edit'

const schema = {
  type: 'page',
  body: {
    type: 'crud',
    api: '/upms/admin/system/list',
    syncLocation: false,
    autoFillHeight: true,
    footerToolbar: [
      'statistics',
      'switch-per-page',
      'pagination'
    ],
    autoGenerateFilter: {
      showBtnToolbar: false,
      columnsNum: 3
    },
    headerToolbar:[
      {
        type: 'button',
        actionType: 'dialog',
        align: 'right',
        label: '新增',
        icon: 'fa fa-plus pull-left',
        primary: true,
        dialog: {
          title: '新增子系统',
          closeOnEsc: true,
          showErrorMsg: false,
          size: 'md',
          body: addPage
        }
      }
    ],
    columns: [
      {
        name: 'id',
        label: 'Id',
      },
      {
        name: 'systemName',
        label: '系统名称',
        searchable: {
          type: 'input-text',
          name: 'systemName',
          label: '系统名称'
        }
      },
      {
          name: 'systemCode',
          label: '系统编码',
          searchable: {
            type: 'input-text',
            name: 'systemCode',
            label: '系统编码'
          }
      },
      {
          name: 'title',
          label: '标题',
      },
      {
          name: 'basePath',
          label: '系统路径',
      },
      {
          type: 'mapping',
          name: 'showInPortal',
          label: '是否在portal显示',
          map: {
            "0": "<span class='label label-warning'>否</span>",
            "1": "<span class='label label-success'>是</span>",
          }
      },
      {
          name: 'group',
          label: '分组',
      },
      {
        type: 'operation',
        label: '操作',
        buttons: [
          {
            label: '修改',
            actionType: 'dialog',
            dialog: {
              title: '编辑子系统',
              closeOnEsc: true,
              showErrorMsg: false,
              size: 'md',
              body: editPage
            }
          },
          {
            label: '删除',
            type: 'button',
            level: 'danger',
            actionType:'ajax',
            confirmText: '确认要删除该记录？',
            api: {
              url: '/upms/admin/system/delete?id=${id}',
              method: 'post',
              data:{}
            },
          }
        ]
      }
    ]
  }
}

</script>
